<!-- File: /app/View/Pages/index.ctp -->

<h1>Categories</h1>

<?php echo $this->Html->link('Add categorie', array('action' => 'add'), array('class' => 'button'));?>
<table>
    <tr>
        <th>Id</th>
        <th>Nom</th>
		<th>Sous-catégories</th>
        <th>Actions</th>
    </tr>

    <!-- Here is where we loop through our $pages array, printing out page info -->

    <?php foreach ($categories as $category): ?>
    <tr>
        <td><?php echo $category['Category']['id']; ?></td>
        <td>
            <?php echo $category['Category']['name'] ?>
        </td>
		<td>
			<ul>
			<?php foreach ($category['Children'] as $subcategory): ?>
				<li><?php echo $subcategory['name']?></li>
			<?php endforeach;?>
			</ul>
		</td>
		<td>
			<?php
				echo $this->Html->link('Edit', array('action' => 'edit', $category['Category']['id']), array('class' => 'button'));
				echo $this->Form->postLink('Delete', array('action' => 'delete', $category['Category']['id']),array('confirm' => 'Are you sure?', 'class' => 'button'));
			?>
		</td>
    </tr>
    <?php endforeach; ?>
    <?php unset($page); ?>
</table>